* Presidential Impeachment and the New Political Instability                   .
* Models for Chapter 5                                                         .
* Anibal Perez-Linan                                                           .
* University of Pittsburgh                                                     .

* Use datast no. 3_Chapter_5.dta'                                              .

tsset Case Weeks
* Note that you can only 'tsset' the data by defining T as weeks in office,    .
* which basically means that there are always gaps between observations        .
* (since some polls took place every two weeks, others every four, and         .
*  others every twelve weeks)                                                  .

*** Table 5.2 ***************************************************************  .
* 5.2.1 Fixed effects model                                                    .
xtreg   A S Involved Honey i u Adjustment     , fe
* Alternative with inflation logged                                            .
xtreg   A S Involved Honey ln_i u Adjustment  , fe

* 5.2.2 Fixed effects with transformed dependent variable                      .
*  Linearization of proportion: At = ln(A/(100-A))                             .
xtreg   At S Involved Honey i u Adjustment    , fe

* 5.2.3 Panel-corrected standard errors                                        .
xtpcse   A S Involved Honey i u Adjustment bra ven col ecu1 ecu2 par1 , p

* 5.2.4 Weighted fixed effects model                                           .
reg     A S Involved  Honey i u Adjustment bra ven col ecu1 ecu2 par1 [pweight=w]

* 5.2.5 Fixed effects Tobit                                                    .
tobit A S Involved Honey i u Adjustment bra ven col ecu1 ecu2 par1 , ll(0) ul(100)


*** Table 5.3 ***************************************************************  .

* 5.3.1-2 Instruments                                                          .
* i - OLS purges variance owed to A(t-1) and produces residual I               .
reg S          lag_A Month
predict I_S, residuals
* ii - Logit since Involved is dichotomous                                     . 
* Model includes S because instrument will also predict S                      .
logit Involved S lag_A Month  
predict I_Involved, deviance
corr A I_S I_Involved

* 5.3.3-5 Fixed effects, instrumental variable regression                       .
xtivreg A (S Involved = I_S I_Involved) Honey i u Adjustment , fe first

* Alternative with ln of inflation                                              .
xtivreg A (S Involved = I_S I_Involved) Honey ln_i u Adjustment , fe

* Check with linearized DV                                                      .
xtivreg At (S Involved = I_S I_Involved) Honey i u Adjustment , fe





